import router from '@system.router';
import prompt from '@system.prompt';
import device from '@system.device';

export default {
    data: {
        title: "",
        selectImage: [],
        imagePath: "",
        imageAttr: {
            width: '120px'
        }
    },
    onInit() {
        this.title = this.$t('strings.world');
        var that = this;
        device.getInfo({
            success: function (data) {
                if (data.deviceType == "phone") {
                    if (data.windowHeight > data.windowWidth) {
                        that.imageAttr.width = data.windowWidth * 0.3 + "px";
                    } else {
                        that.imageAttr.width = data.windowHeight * 0.3 + "px";
                    }
                }
                console.log("str 当前横竖屏" + data.language);
                console.log("str 当前高度" + data.windowHeight);
                console.log("str 当前宽度" + data.windowWidth);
                console.log("str 设备类型" + data.deviceType);
            },
            fail(data, code) {
            },
            complete() {
            }
        })
    },
    onShow() {
        var appData = this.$app.$def.data;
        console.log("router.push console " + appData.imageSelect);
        if (appData.imageSelect != undefined) {
            this.selectImage = appData.imageSelect;
            if (this.selectImage.length > 0) {
                this.imagePath = this.selectImage[0]
            }
            setTimeout(() => {
                var that = this;
                prompt.showToast({
                    message: "当前选择路径：" + JSON.stringify(that.selectImage)
                });
            }, 1000)
        }
    },
    select() {
        router.push({
            // 指定要跳转的页面
            uri: 'pages/select_image/select_image',
            params: {
            //本次可以选择图片的上限
                imageCount: 2,
            //已经选择的图片
                selectImage: this.selectImage,
            }
        })
    }
}
